// 代码块 importM
import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
      home: Scaffold(
          resizeToAvoidBottomInset: false,
          appBar: AppBar(
            title: const Text("你好Flutter"),
          ),
          body: const Column(
            children: [
            MyApp(),
            SizedBox(height: 20,),
            Circular(),
            SizedBox(height: 20,),
            ClipImage(),
            SizedBox(height: 20,),
            LocalImage()
          ])
        )
      )
    );
}

// 代码块 statelessW
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Center(
            child: Container(
              height: 300,
              width: 300,
              decoration: const BoxDecoration(
                color: Colors.yellow
              ),
              child: Image.network("https://tse3-mm.cn.bing.net/th/id/OIP-C.FYx55PIoNajL-lEV5UhFlAHaNK?rs=1&pid=ImgDetMain",
                scale: 2, // 缩放
                alignment: Alignment.centerLeft, // 居左
                fit: BoxFit.cover // fill 充满整个容器会压缩 cover 剪裁充满容器 fitWidth 宽度充满
              )
            ),
          );
  }
}

class Circular extends StatelessWidget {
  const Circular({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 150,
      width: 150,
      decoration: BoxDecoration(
        color: Colors.yellow,
        borderRadius: BorderRadius.circular(100),
        image: const DecorationImage(image: NetworkImage("https://tse3-mm.cn.bing.net/th/id/OIP-C.FYx55PIoNajL-lEV5UhFlAHaNK?rs=1&pid=ImgDetMain"),
          fit: BoxFit.cover,
        )
      ),
    );
  }
}

class ClipImage extends StatelessWidget {
  const ClipImage({super.key});

  @override
  Widget build(BuildContext context) {
    return ClipOval(
      child: Image.network(
        "https://tse3-mm.cn.bing.net/th/id/OIP-C.FYx55PIoNajL-lEV5UhFlAHaNK?rs=1&pid=ImgDetMain",
        width: 150,
        height:150,
        fit: BoxFit.cover
      ),
    );
  }
}

// 加载本地图片
class LocalImage extends StatelessWidget {
  const LocalImage({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 150,
      height: 150,
      decoration: const BoxDecoration(
        color: Colors.yellow
      ),
      child: Image.asset("images/a.jpeg", fit: BoxFit.cover)
    );
  }
}